package com.carpool.request;
import com.carpool.message.ReplyMessage;
import com.carpool.message.RequestMessage;
public abstract class Request {
	public interface IRequestListener {
	/**
	 * Invoked when reply have become available.
	 * 
	 * @param ReplyMessage
	 *            the reply come from server.
	 */
	public abstract void onReplyAvailable(ReplyMessage rpl);
	/**
	 * Invoked when reply are not available.
	 */
	public abstract void onReplyNotAvailable();
	}

	private IRequestListener listener;
	public  void sendMessage(RequestMessage rqst,IRequestListener listener)
	{
		this.listener = listener;
		postRequest(rqst);
	}
public  abstract void postRequest(RequestMessage rqst);
	protected void onReplyAvailable(ReplyMessage rpl) {
		if (listener != null) {
			listener.onReplyAvailable(rpl);
		}
	}

	protected void onReplyNotAvailable() {
		if (listener != null) {
			listener.onReplyNotAvailable();
		}
	}
}
